﻿using AuthCenter_HuangJingtao.Domain;
using AuthCenter_HuangJingtao.ErrorCode;
using AuthCenter_HuangJingtao.Infrastructure.Imterfaces;
using AuthCenter_HuangJingtao.Read.Api.Application.Command.AppaLL;
using MediatR;
using Microsoft.EntityFrameworkCore;

namespace AuthCenter_HuangJingtao.Read.Api.Application.CommandHandler.AppHandler
{
    public class ShowCitryCommandHandler : IRequestHandler<ShowCitryCommand, ApiResult<List<Citys>>>
    {
        IBaseReponsitory<Citys> citys;

        public ShowCitryCommandHandler(IBaseReponsitory<Citys> citys)
        {
            this.citys = citys;
        }

        public async Task<ApiResult<List<Citys>>> Handle(ShowCitryCommand request, CancellationToken cancellationToken)
        {
            var list =await citys.GetQuery().Where(c=>c.AddressId==request.Addrss_Id).ToListAsync();
            return new ApiResult<List<Citys>> 
            {
                Code=ApiEnum.Success,
                Message = "获取成功",
                Data=list
            };
        }
    }
}
